package com.simon.train.${module}.controller;


import com.simon.train.common.Result.Result;
import com.simon.train.common.context.LoginMemberContext;
import com.simon.train.common.vo.PageVO;
import com.simon.train.${module}.dto.${Domain}QueryDto;
import com.simon.train.${module}.dto.${Domain}SaveDto;
import com.simon.train.${module}.service.${Domain}Service;
import com.simon.train.${module}.vo.${Domain}QueryVO;
import jakarta.annotation.Resource;
import jakarta.validation.Valid;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/${domain}")
public class ${Domain}Controller {

    @Resource
    private ${Domain}Service ${domain}Service;

    @PostMapping("/save")
    public Result<Object> Save${Domain}(@Valid @RequestBody ${Domain}SaveDto ${domain}SaveDto){
        ${domain}Service.Save${Domain}(${domain}SaveDto);
        return new Result<>();
    }

    @GetMapping("/queryList")
    public Result<PageVO<${Domain}QueryVO>> ${Domain}QueryList(@Valid ${Domain}QueryDto ${domain}QueryDto){
         /**
         * ${module}Id通过线程变量获取 从而不需要由前端传入 保证了效率和安全性
         */
        PageVO<${Domain}QueryVO> lists = ${domain}Service.Query${Domain}List(${domain}QueryDto);
        return new Result<>(lists);
    }

    @DeleteMapping("/delete/{id}")
    public Result<Object> Delete${Domain}(@PathVariable("id") Long id){
        ${domain}Service.delete${Domain}(id);
        return new Result<>();
    }

}
